package domain;

import java_persistence.ServicesMapper;

/**
 * @author joseph simoneau <simoneau@gatech.edu>
 *
 */
public class Services {

	private String service_name;
	private Float price;

	public Services() {
		super();
	}
	
	public Services( String name, Float p) {
		super();
		
		this.service_name = name;
		this.price = p;
	}

	public String getService_name() {
		return service_name;
	}
	public float getPrice() {
		return price;
	}


	public void setService_name(String service_name) {
		this.service_name = service_name;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	
	
	// CREATES
	
	/**Stores 'this''s information in the database.  
	 * @param servmap retrieved from a valid, open SqlSession object.
	 */
	public void create(ServicesMapper servmap) {
		if( this.service_name!=null && this.price!=null) {
			servmap.create( this.service_name, this.price );
		}
	}
	
	// RETREVES
	
	/**Retrieves a service entry from the database and populates 'this' with its information. 
	 * @param serv_name the name of the service to be retrieved 
	 * @param servmap retrieved from a valid, open SqlSession object.
	 * @return the described Services object.
	 */
	public static Services get_service_by_name(String serv_name, ServicesMapper servmap) {
		return servmap.get_service_by_name(serv_name);
	}
	
	
	// UPDATES

	/**Updates the price of 'this' in the database to the value currently stored in 'this'
	 * @param servmap retrieved from a valid, open SqlSession object.
	 */
	public void update_price(ServicesMapper servmap) {
		if( this.service_name!=null && this.price!=null) {
			servmap.update_price( this.service_name, this.price);
		}
	}
	
	// DELETES

	/**Deletes 'this''s entry from the database.
	 * @param servmap retrieved from a valid, open SqlSession object.
	 */
	public void delete(ServicesMapper servmap) {
		servmap.delete( this.service_name ) ;
		
	}
	
	
	
	

}
